#pragma once

#include <atlbase.h>
#include <atlconv.h>

#define USES_UTF8_CONVERSION \
	USES_CONVERSION; \
	_acp = CP_UTF8; //936

#define USES_GB_CONVERSION \
	USES_CONVERSION; \
	_acp = CP_UTF8;

#define W2UTF8(lpw) (\
	((_lpw = lpw) == NULL) ? NULL : (\
	(_convert = (WideCharToMultiByte(CP_UTF8, 0, lpw, wcslen(lpw), NULL, 0, NULL, NULL)+1), \
	(_convert>INT_MAX) ? NULL : \
	ATLW2AHELPER((LPSTR) alloca(_convert), _lpw, _convert, _acp))))



#if  defined (UNICODE) || defined (_UNICODE)  
#define T2UTF8 W2UTF8  
#define UTF82T A2T  
#else  
#define T2UTF8 A2UTF8  
#define UTF82T UTF82A  
#endif  